import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolDemo {
    public static void main(String[] args) {
        //1.创建服务，创建线程池
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        //newFixedThreadPool  参数为 线程池大小
        executorService.execute(new Thread_());
        executorService.submit(new Thread_());
        executorService.execute(new Thread_());
        executorService.execute(new Thread_());
        executorService.execute(new Thread_());
        executorService.execute(()->{
            System.out.println(Thread.currentThread().getName()+"...");
        });
        //关闭服务
        executorService.shutdown();
    }
}


class Thread_ implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() );
    }
}